import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;


public class MoveFrame extends Frame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final int HAUTEUR = 400;
	private static final int LARGEUR = 300;
	private JPanel movePanel = new JPanel();
	private Graphics2D g2 ;
	
	BufferedImage imgMemoire;
	int X = 70;
	int Y = 70;
	
	public static void main (String[] args){
		new MoveFrame();
	}
	
	public MoveFrame(){
		this.setTitle("Mouvement d'image");
		this.setSize(LARGEUR,HAUTEUR);
		this.setLayout(new BorderLayout());
		this.addKeyListener(new Controler(this));
		this.add(movePanel, "Center");
		
		this.addWindowListener(new FermerFenetre(this));
		
		try {
			imgMemoire = ImageIO.read(new File("C:/DATA/Images/link.jpg"));

		} catch (IOException e) {
			System.out.println("Erreur de chargement d'image");
		} 
		
		MonThread t = new MonThread(this);
		t.start();
		
		this.setVisible(true);
	}
	public void paint (Graphics g) {
	    g2 = (Graphics2D) g;
		g2.drawImage(imgMemoire,null, X, Y);
	    
	}
	public void deplacer(int newX, int newY){
		X = newX;
		Y = newY;
		//repaint();
		
	}
}
